<template>
	<view class="content">
		<navbar title='合同范本' :isback="true">
		</navbar>
		<view class="souview">
			<view class="souitem">
				<image class="icon_sousuo" src="@/static/new/icon_sousuo.png"></image>
				<u-input placeholder="关键词搜索" :clearable="true" :border="false" v-model="value"></u-input>
				<view class="soubtn">搜索</view>
			</view>
		</view>
		<view class="fone plr">
			<text class="ftit" style="margin-bottom: 45rpx;">热门搜索</text>
			<view class="flist">
				<view class="fitem" v-for="(item,index) in classlist" :key="index" @click="moreRouter(item)">
					<image class="ficon" :src="item.logo"></image>
					<text>{{item.name}}</text>
				</view>
				<!-- <view class="fitem" @click="moreRouter">
					<image class="ficon" src="@/static/new/heeight.png"></image>
					<text>更多合同</text>
				</view> -->
			</view>
			<view class="shenhe">
				<view class="shenitem">
					<image class="shenone" src="@/static/new/shenone.png"></image>
					<text class="shentit">更多合同</text>
				</view>
				<view class="shenitem">
					<image class="shenone" src="@/static/new/shentwo.png"></image>
					<text class="shentit">资质认证</text>
				</view>
				<view class="shenitem">
					<image class="shenone" src="@/static/new/shenthree.png"></image>
					<text class="shentit">超1w次下载</text>
				</view>
			</view>
		</view>
		<view class="fone plr">
			<text class="ftit">精选合同范本</text>
			<view class="leiview">
				<scroll-view scroll-x class="leiscview">
					<view class="leiitem" :class="class_selectinfo.id==item.id?'lactive':''" v-for="(item,index) in class_selected" :key="index" @click="getClass(item)">{{item.name}}</view>
					
				</scroll-view>
			</view>

			<view class="list">
				<view class="item" v-for="(item,index) in contract" :key="index"  @click="getDetail(item)">
					<image class="tubg" :src="item.img"></image>
					<view class="botview">
						<text class="biaoti txt">{{item.name}}</text>
						<text class="pjia">￥<text class="pnum">{{item.price}}</text></text>
					</view>
				</view>
				<view class="nodata" v-if="contract == ''">
					<u-empty text="暂无数据" mode="list" ></u-empty>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
    // import Mine from "@/components/Mine/Mine"; 
	export default {
		components:{
			// Mine
		},
		data() {
			return {
				titleStyle:{
					fontWeight: 'bold',
					fontSize: '36rpx',
					color: '#111111',
				},
				value:'',
				info:{},
				classlist:[],
				class_selected:[],
				class_selectinfo:{},
				contract:[]

			}
		},
		onLoad() {
			this.getinit();
			// this.$store.commit('initWebsocket');
		},
		onShow() {
			// if(!this.info){
			// 	this.getstatistic();//用户资产
			// }
			
			
		},
		onPullDownRefresh() {
			// console.log("+++")
			// // uni.stopPullDownRefresh();
			// this.getstatistic();//用户资产
			// setTimeout(() => {
			// 	uni.stopPullDownRefresh();
			// }, 1000);
		},
		methods: {
			async getinit(){
				let res = await this.$u.api.contract({
				});
				console.log(res)
				this.info = res
				this.classlist = res.class
				this.class_selected = res.class_selected
				this.class_selectinfo = this.class_selected[0]
				// this.contract = res.contract
				this.getlist()
			},
			async getlist(){
				let res = await this.$u.api.contract({
					class_id:this.class_selectinfo.id
				});
				this.contract = res.contract
			},
			getClass(item){
				this.class_selectinfo = item
				this.getlist()
			},
			getgong(){
				this.navrouter("/pages/TPage/Gonglist");
			},
			getmine(){
				this.mshow = true
				uni.hideTabBar();
			},
			mineclose(){
				this.mshow = false
				uni.showTabBar();
			},
			geteyes(){
				this.iseyes = !this.iseyes
			},
			getDetail(item){
				this.navrouter("/pages/StudPage/Detail?id="+item.id);
			},
			getlogin(){
				uni.redirectTo({
					url: '/pages/login/login'
				})
			},
			moreRouter(item){
				this.navrouter("/pages/StudPage/FindContract?id="+item.id+'&name='+item.name);
			}


		}
	}
</script>

<style scoped lang="scss">
	.content {
		min-height: 100vh;
		padding-bottom: 120rpx;
		background-color: #fff;

		.souview{
			background-color: #fff;
			padding: 20rpx 30rpx 0;
			display: flex;
			flex-direction: row;
			align-items: center;
			
			.souitem{
				height: 78rpx;
				background: #F5F5F5;
				border-radius: 39rpx;
				display: flex;
				align-items: center;
				flex-direction: row;
				padding: 0 23rpx;
				width: 100%;
				.icon_sousuo{
					width: 24rpx;
					height: 24rpx;
					margin-right: 15rpx;
				}
				.soubtn{
					margin-left: 20rpx;
					width: 100rpx;
					height: 50rpx;
					background: #3E65E5;
					border-radius: 25rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
				}
			}
		}
		.fone{
			margin-top: 40rpx;
			.flist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.fitem{
					width: 25%;
					display: flex;
					flex-direction:column;
					align-items: center;
					justify-content: center;
					margin-bottom: 44rpx;
					text{
						display: inline-block;
						margin-top: 13rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
					}
					.ficon{
						width: 80rpx;
						height: 80rpx;
						border-radius: 15rpx;
					}
				}
			}
			.shenhe{
				height: 60rpx;
				background: #F3F6F9;
				border-radius: 10px;
				padding: 0 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				.shenitem{
					width: 33.33%;
					display: flex;
					flex-direction: row;
					align-items: center;
					border-right: 1rpx solid rgba(62,101,229,0.3);
					justify-content: center;
					.shenone{
						margin-right: 3rpx;
						width: 33rpx;
						height: 33rpx;
					}
					.shentit{
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #3C66DE;

					}
				}
				.shenitem:last-child{
					border-right: none;
				}
			}

			.leiview{
				width: 100%;
				.leiscview{
					white-space: nowrap;
					// overflow-x: auto;
					.leiitem{
						display: inline-block;
						padding: 20rpx 40rpx;
						background: #EEEEEE;
						border-radius: 16rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
						margin-right: 20rpx;
					}
					.lactive{
						background: #3E65E5;
						color: #fff;

					}
				}
				
			}
		}
		.list{
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			margin-top: 30rpx;

			.item{
				width: 48%;
				display: flex;
				flex-direction: column;
				margin-bottom: 30rpx;
				// border: 1rpx solid #eee;
				box-shadow: 0px 3rpx 9rpx 0px rgba(109,109,109,0.1);
				
				.tubg{
					width: 100%;
					height: 330rpx;
					margin-bottom: 20rpx;
				}
				.botview{
					display: flex;
					flex-direction: column;
					padding: 10rpx ;
				}
				.biaoti{
					display: inline-block;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;
				}
				.pjia{
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 26rpx;
					color: #E53E3E;
					display: block;
					margin-top: 20rpx;
					.pnum{
						font-size: 36rpx;
					}
				}
			}
			.item:nth-child(even){
				margin-left: auto;
			}
		}
		.txt {
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		.plr{
			padding: 0 30rpx;
		}
		.ftit{
			display: block;
			margin-bottom: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 36rpx;
			color: #111111;
		}



	}
</style>